package com.woniuxy.controller;

import com.woniuxy.anno.BloomFilterAnnotation;
import com.woniuxy.entity.Department;
import com.woniuxy.entity.SubDepartment;
import com.woniuxy.entity.dto.DepartmentDTO;
import com.woniuxy.entity.dto.SubDepartmentDTO;
import com.woniuxy.service.DeptService;
import com.woniuxy.util.PageData;
import com.woniuxy.util.ResponseData;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;

@RestController
@RequestMapping("/dept")
public class DeptController {

    @Resource
    private DeptService deptService;
    @PostMapping("/queryAllDept")
    public ResponseData<?> queryAllDept(@RequestBody PageData<DepartmentDTO> pageData) throws ParseException {
        return deptService.queryAllDept(pageData);
    }


    @PostMapping("/querySubDept")
    public ResponseData<?> querySubDept(@RequestBody Department department){
        return deptService.queryAllSubDept(department.getId());
    }

    @PostMapping("/addDept")
    public ResponseData<?> addDept(@RequestBody Department department){
        return deptService.addDept(department);
    }

    @PostMapping("/saveUpdateDept")
    public ResponseData<?> saveUpdateDept(@RequestBody Department department){
        return deptService.saveUpdateDept(department);
    }

    @PostMapping("/updateStatus")
    public ResponseData<?> updateStatus(@RequestBody Department department){
        return deptService.updateStatus(department);
    }

    @PostMapping("/addSubDept")
    public ResponseData<?> addSubDept(@RequestBody SubDepartment subDepartment){
        return deptService.addSubDept(subDepartment);
    }

    @PostMapping("/updateSubDeptSave")
    public ResponseData<?> updateSubDeptSave(@RequestBody SubDepartment subDepartment){
        return deptService.updateSubDeptSave(subDepartment);
    }

    @PostMapping("/updateSubStatus")
    public ResponseData<?> updateSubStatus(@RequestBody SubDepartment subDepartment){
        return deptService.updateSubStatus(subDepartment);
    }
}
